USE [AuctionDB]
GO

ALTER TABLE [dbo].[Auction] DROP CONSTRAINT [FK_Auction_User1]
GO

ALTER TABLE [dbo].[Auction] DROP CONSTRAINT [FK_Auction_User]
GO

ALTER TABLE [dbo].[Auction] DROP CONSTRAINT [FK_Auction_ProductType]
GO

/****** Object:  Table [dbo].[Auction]    Script Date: 7/18/2013 1:05:36 PM ******/
DROP TABLE [dbo].[Auction]
GO

/****** Object:  Table [dbo].[Auction]    Script Date: 7/18/2013 1:05:36 PM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Auction](
	[AuctionID] [int] IDENTITY(1,1) NOT NULL,
	[Creator] [int] NOT NULL,
	[LastBidder] [int] NULL,
	[ProductType] [int] NOT NULL,
	[ProductName] [nvarchar](50) NOT NULL,
	[InitialPrice] [float] NOT NULL,
	[LastPrice] [float] NULL,
	[BeginTime] [time](7) NOT NULL,
	[BeginDate] [date] NOT NULL,
	[EndTime] [time](7) NOT NULL,
	[EndDate] [date] NOT NULL,
	[State] [nvarchar](20) NOT NULL,
	[PaymentTypes] [int] NOT NULL,
	[ShipmentTypes] [int] NOT NULL,
 CONSTRAINT [PK_Auction] PRIMARY KEY CLUSTERED 
(
	[AuctionID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

ALTER TABLE [dbo].[Auction]  WITH CHECK ADD  CONSTRAINT [FK_Auction_ProductType] FOREIGN KEY([ProductType])
REFERENCES [dbo].[ProductType] ([TypeID])
GO

ALTER TABLE [dbo].[Auction] CHECK CONSTRAINT [FK_Auction_ProductType]
GO

ALTER TABLE [dbo].[Auction]  WITH CHECK ADD  CONSTRAINT [FK_Auction_User] FOREIGN KEY([Creator])
REFERENCES [dbo].[User] ([UserID])
GO

ALTER TABLE [dbo].[Auction] CHECK CONSTRAINT [FK_Auction_User]
GO

ALTER TABLE [dbo].[Auction]  WITH CHECK ADD  CONSTRAINT [FK_Auction_User1] FOREIGN KEY([LastBidder])
REFERENCES [dbo].[User] ([UserID])
GO

ALTER TABLE [dbo].[Auction] CHECK CONSTRAINT [FK_Auction_User1]
GO

